package com.javasm.error;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @className: JavasmExceptionAdvice
 * @description
 * @author: gfs
 * @date: 2024/7/3 14:46
 * @version: 0.1
 * @since : jdk11
 */
@RestControllerAdvice(basePackages = {"com.javasm"})
public class JavasmExceptionAdvice {

    @ExceptionHandler(JavasmException.class)
    public ResponseEntity f1(JavasmException e){
        e.printStackTrace();
        //当异常产生的时候,触发了此方法,
        //当前方法返回的数据,就是产生异常的时候,返回的数据
        ExceptionEnum exceptionEnum = e.getExceptionEnum();
        return ResponseEntity.ok(exceptionEnum);
    }
}
